<template>
  <div class="user">
    <transition mode="out-in">
      <Table :tableConfig="tableConfig" v-if="!showBack" />
      <Form :formConfig="formConfig" v-else />
    </transition>
    <div class="action-icon">
      <el-button v-if="!showBack" type="primary" :icon="Plus" circle  @click="togglePage" />
      <el-button v-else type="warning" :icon="Back" circle  @click="togglePage" />
    </div>
  </div>
</template>

<script lang="ts" setup>
import { reactive, ref } from 'vue'

import Table from '@/components/table'
import Form from '@/components/form'
import { useTableConfig, useFormConfig } from './config'
import { Plus, Back } from '@element-plus/icons-vue'

const tableConfig = reactive(useTableConfig())
const formConfig = reactive(useFormConfig())

const showBack = ref(false)
const togglePage = () => {
  showBack.value = !showBack.value
}
</script>

<style lang="less" scoped>
.user {
  width: 100%;
  .action-icon {
    position: absolute;
    bottom: 12px;
    right: 20px;
  }
}
</style>
